package com.thoughtworks.jspecsupport.settings;

import java.io.File;

public class SettingsValidator {

    public void validate(String prodJsFolder, String testLibFolder)  {
        String errors = validateFolderExist("Prod js folder", prodJsFolder);
        if (errors.length() != 0) errors += "\n";

        errors += validateFolderExist("Test lib folder", testLibFolder);
        if (errors.length() > 0) throw new InvalidSettingsException(errors);
    }

    private String validateFolderExist(String type, String folderPath) {
        if (folderPath == null) {
            return type + " not set yet.";
        } else {
            File folder = new File(folderPath);
            if (folder.exists() && folder.isDirectory()) return "";
            return folder + " is not found.\n";
        }
    }
}
